﻿namespace com.crownpack.probeservice
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml;
    using System.Xml.Linq;

    using SharePointService;

    class Program
    {
        #region Methods

        public XElement GetAll( )
        {
            using ( Lists o = new Lists( ) )
            {
                XElement getListItem = o.GetListItem( "cp/initiatives", o.BuildQueryElement( o.BuildOrderByElement( orderby.All ), query.All ) );
                return getListItem;
            }
        }

        static void Main( string[ ] args )
        {
            Program o = new Program( );
            o.GetAll( );
        }

        #endregion Methods

        #region Nested Types

        class orderby
        {
            #region Fields

            public const string All = "<FieldRef Name='Title' Ascending='True'/>";
            public const string ByCourseSequence = "<FieldRef Name='lmap_CourseSequence' Ascending='True' />";
            public const string ById = "";
            public const string ByIds = "<FieldRef Name='Title' Ascending='True'/>";
            public const string ByTitle = "<FieldRef Name='Title' Ascending='True'/>";

            #endregion Fields
        }

        class query
        {
            #region Fields

            public const string All = "";
            public const string ById = "<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq></Where>";
            public const string ByIds_Eq = "<Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq>";
            public const string ByIds_Or = "<Or>{0}{1}</Or>";
            public const string ByIds_Where = "<Where>{0}</Where>";
            public const string BySeriesTitle = "<Where><Eq><FieldRef Name='lmap_SeriesTitle' /><Value Type='Lookup'>{0}</Value></Eq></Where>";
            public const string ByTitle = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>{0}</Value></Eq></Where>";

            #endregion Fields
        }

        #endregion Nested Types
    }
}